package com.example.demo.auth.controller;

import com.example.demo.auth.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
//  SendSms: '/account/sms',
//  SendSmsErr: '/account/sms_err',
@Slf4j
@RestController
@RequestMapping("/account")
public class AccountController {

    @PostMapping("/sms")
    public Mono<Integer> sms() {
        return  Mono.just(22222);
    }

    @PostMapping("/sms_err")
    public Mono<ResponseEntity<Void>> smsErr(@RequestBody Mono<User> user) {
        return user.mapNotNull(info -> {
            log.info("[测试接口] 注销成功");
            return new ResponseEntity<Void>(HttpStatus.OK);
        }).defaultIfEmpty(new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR));
    }
}
